package util.libraries;

import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;


public class ImageLibrary extends MapToFileLibrary
{

    protected ArrayList<BufferedImage> myImages;
    
    public ImageLibrary (File dir)
    {
        super(dir);
    }
    public ImageLibrary (String dir)
    {
        super(dir);
    }
    @Override
    protected void addMappingElement (File add)
    {
        System.out.println("hi");
        try
        {
            myImages.add(ImageIO.read(add));
        }
        catch (Exception e)
        {
            throw new LibraryException(LibraryException.READING_FAIL);
        }
        
        
    }

    @Override
    public void initialize()
    {
        super.initialize();
        myImages = new ArrayList<BufferedImage>();
        myImages.trimToSize();
    }
    
    @Override
    public Object getMapElementByKey (Object key)
    {
        
        return myImages.get(getIndexByID(key));
    }
    @Override
    public Object getMapElementByIndex (Integer index)
    {
        System.out.println(myImages);
        return myImages.get(index);
    }
   

}
